/*
 * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
 * 
 * This software is a confidential and proprietary information of Samsung Electronics, Inc.
 * ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into with Samsung Electronics.
 */

package com.example.sistemacompras.utils;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.view.Display;

public class Utils {

    private Activity mActivity;

    private int mHeight;

    private int mWidth;

    public Utils(Activity activity) {
        this.mActivity = activity;

        Display display = activity.getWindowManager().getDefaultDisplay();
        DisplayMetrics metrics = new DisplayMetrics();
        display.getMetrics(metrics);

        mHeight = metrics.heightPixels;
        mWidth = metrics.widthPixels;

    }

    public float getImageScaleX(Drawable drawable) {
        float width = ((float) drawable.getIntrinsicWidth());
        return (width / mWidth);
    }

    public float getImageScaleY(Drawable drawable) {
        float height = ((float) drawable.getIntrinsicHeight());
        return (height / mHeight);
    }

    public int getStatusBarHeight() {
        int result = 0;
        int resourceId = mActivity.getResources().getIdentifier("status_bar_height", "dimen",
                "android");

        if (resourceId > 0) {
            result = mActivity.getResources().getDimensionPixelSize(resourceId);
        }

        return result;
    }

    public int getWidthInPixels() {
        return mWidth;
    }

    public int getHeightInPixels() {
        return mHeight;
    }
}
